﻿@model DMHelper.Models.DDSheet

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@{
    ViewBag.Title = "ModifFeuille";
}

@Html.ActionLink("Retour", "FeuillesPerso", "Home")
<h2 style="text-align:center;">Feuille du personnage</h2>

<h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">General information</h3>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <table id="Head" border="1" class="table">
            <tr align="center">
                <td colspan="2" style="font-weight:bold">Player Name:</td>
                <td align="left" valign="middle" colspan="3" style="font-weight:bold">
                    @Html.EditorFor(model => model.head.PlayerName.Value)
                    @Html.ValidationMessageFor(model => model.head.PlayerName.Value)
                </td>
                <td colspan="2" style="font-weight:bold">Character Name:</td>
                <td align="left" valign="middle" colspan="3" style="font-weight:bold">
                    @Html.EditorFor(model => model.head.Nom.Value)
                    @Html.ValidationMessageFor(model => model.head.Nom.Value)    
                </td>
            </tr>
            <tr align="center">
                <td style="font-weight:bold">Alignment</td>
                <td>
                    @Html.EditorFor(model => model.head.Alignment.Value)
                    @Html.ValidationMessageFor(model => model.head.Alignment.Value) 
                </td>
                <td style="font-weight:bold">Religion/Deity</td>
                <td align="left" valign="middle">
                    @Html.EditorFor(model => model.head.Deity.Value)
                    @Html.ValidationMessageFor(model => model.head.Deity.Value) 
                </td>
                <td style="font-weight:bold">Race</td>
                <td align="left" valign="middle">
                    @Html.EditorFor(model => model.head.Race.Value)
                    @Html.ValidationMessageFor(model => model.head.Race.Value) 
                </td>
                <td style="font-weight:bold">Gender</td>
                <td>
            @* Vérifier le sexe de la feuille puis ajouter une propriété Checked dans le bon input *@
                    @{
                        if (Model.head.Sex.Value == "M")
                        {
                            @Html.RadioButtonFor(model => model.head.Sex.Value, "M", new { @checked = "checked" })
                            @Html.RadioButtonFor(model => model.head.Sex.Value, "F")
                        } else {
                            @Html.RadioButtonFor(model => model.head.Sex.Value, "M")
                            @Html.RadioButtonFor(model => model.head.Sex.Value, "F", new { @checked = "checked" })
                        }
                    }
                </td>
                <td style="font-weight:bold">Size</td>
                <td>
                    @Html.EditorFor(model => model.head.Size.Value)
                    @Html.ValidationMessageFor(model => model.head.Size.Value)
                </td>
            </tr>
            <tr align="center">
                <td colspan="2" style="font-weight:bold">Classe</td>
                <td colspan="4">
                    @Html.EditorFor(model => model.head.Class.Value)
                    @Html.ValidationMessageFor(model => model.head.Class.Value)
                </td>
                <td colspan="2" style="font-weight:bold">Level</td>
                <td align="left" valign="middle" colspan="2">
                    @Html.EditorFor(model => model.head.Level.Value)
                    @Html.ValidationMessageFor(model => model.head.Level.Value)
                </td>
            </tr>
        </table>
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Abilities and stats</h3>
        <table id="ini" border="1" class="table" align="right">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Initiative =</td>
                <td style="font-weight:bold; background-color:Silver">Base Ini. +</td>
                <td style="font-weight:bold; background-color:Silver">Misc. Ini.</td>
            </tr>
            <tr align="center">
                <td style="font-weight:bold; color:Black">
                    @Html.EditorFor(model => model.stats.Initiative.Value)
                    @Html.ValidationMessageFor(model => model.stats.Initiative.Value)
                </td>
                <td style="font-weight:bold; background-color:Silver">
                    @Html.EditorFor(model => model.stats.baseInitative.Value)
                    @Html.ValidationMessageFor(model => model.stats.Initiative.Value)
                </td>
                <td style="font-weight:bold; background-color:Silver">
                    @Html.EditorFor(model => model.stats.miscInitiative.Value)
                    @Html.ValidationMessageFor(model => model.stats.Initiative.Value)
                </td>
            </tr>
        </table>
        <table id="Speed" border="1" class="table" align="right" style="margin-right:100px">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Speed</td>
            </tr>
            <tr align="center">
                <td style="font-weight:bold; color:Black">
                    @Html.EditorFor(model => model.stats.Speed.Value)
                    @Html.ValidationMessageFor(model => model.stats.Speed.Value)
                </td>
            </tr>
        </table>
        <br />    
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Ability</h3>
        <table id="Abilities" border="1" class="table">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Ability</td>
                <td style="font-weight:bold; background-color:Silver">Total Score</td>
                <td style="font-weight:bold; background-color:Silver">Base Score</td>
                <td style="background-color:Gray; color:Silver">Ability Modifier</td>
                <td style="background-color:Gray; color:Silver">Temp. Bonus</td>
            </tr>
            @* Boucler pour chq abilité*@
            @foreach (var item in Model.stats.listAbilities.Values)
            {
                <tr align="center">
                    <td style="font-weight:bold; color:Black">
                        @item.abilityName.Value
                    </td>
                    <td style="font-weight:bold; color:Black">
                        @Html.EditorFor(model => @item.tempScore.Value)
                        @Html.ValidationMessageFor(model => @item.tempScore.Value)
                    </td>
                     <td style="font-weight:bold; background-color:Silver">
                        @Html.EditorFor(model => @item.baseScore.Value)
                        @Html.ValidationMessageFor(model => @item.baseScore.Value)
                     </td>
                     <td style="font-weight:bold; background-color:Silver">
                        @Html.EditorFor(model => @item.abilityModifier.Value)
                        @Html.ValidationMessageFor(model => @item.abilityModifier.Value)
                     </td>
                     <td style="background-color:Gray; color:Silver">
                        @Html.EditorFor(model => @item.tempabilityModifier.Value)
                        @Html.ValidationMessageFor(model => @item.tempabilityModifier.Value)
                     </td>
                </tr>
            }
        </table>
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Saves and HP</h3>
        <table id="HP" border="1" class="table" align="right">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Total HP</td>
                <td style="font-weight:bold; background-color:Silver">Current HP</td>
            </tr>
            <tr align="center">
                <td style="font-weight:bold; color:Black">
                    @Html.EditorFor(model => model.combat.MaxHP.Value)
                    @Html.ValidationMessageFor(model => model.combat.MaxHP.Value)
                </td>
                <td style="font-weight:bold; background-color:Silver">
                    @Html.EditorFor(model => model.combat.currentHP.Value)
                    @Html.ValidationMessageFor(model => model.combat.currentHP.Value)
                </td>
            </tr>
        </table>
        <table id="Saves" border="1" class="table">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Save</td>
                <td style="font-weight:bold">Total</td>
                <td style="font-weight:bold">Base</td>
                <td style="font-weight:bold">Ability</td>
                <td style="font-weight:bold">Magic</td>
                <td style="font-weight:bold">Misc.</td>
                <td style="font-weight:bold">Temp.</td>
            </tr>
            @*Boucler pour tous les save*@
            
            @foreach (var item in Model.savingThrows.listAbilities.Values)
            {
                <tr align="center">
                    <td style="font-weight:bold; color:Black">
                        @item.SavingThrowName.Value
                    </td>
                    <td>
                        @item.TotalSave.Value
                    </td>
                    <td>
                        @Html.EditorFor(model => @item.baseSave.Value)
                        @Html.ValidationMessageFor(model => @item.baseSave.Value)
                    </td>
                    <td>
                        @Html.EditorFor(model => @item.abilityBonus.Value)
                        @Html.ValidationMessageFor(model => @item.abilityBonus.Value)
                    </td>
                    <td>
                        @Html.EditorFor(model => @item.magicalBonus.Value)
                        @Html.ValidationMessageFor(model => @item.abilityBonus.Value)
                    </td>
                    <td>
                        @Html.EditorFor(model => @item.miscBonus.Value)
                        @Html.ValidationMessageFor(model => @item.abilityBonus.Value)
                    </td>
                    <td>
                        @*Insérer Bonus temporaire ici*@
                    </td>
                </tr>
            }
        </table>
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Armor class</h3>
        <table id="AC" border="1" class="table">
            <tr align="center">
                <td style="font-weight:bold; color:Black">AC:</td>
                <td style="font-weight:bold">
                    @Html.LabelFor(model => model.ac.TotalAC.Value)
                </td>
                <td style="font-weight:bold; color:Black">= 10 + </td>
                <td style="font-weight:bold; color:Black">Armor:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ArmorBonus.Value)
                    @Html.ValidationMessageFor(model => model.ac.ArmorBonus.Value)
                </td>
                <td style="font-weight:bold; color:Black">Shield:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ShieldBonus.Value)
                    @Html.ValidationMessageFor(model => model.ac.ShieldBonus.Value)
                </td>
                <td style="font-weight:bold; color:Black">Dex:</td>
                <td>
                    @Html.LabelFor(model => model.ac.DexBonus.Value)
                </td>
                <td style="font-weight:bold; color:Black">Size:</td>
                <td>
                    @Html.EditorFor(model => model.ac.SizeModifier.Value)
                    @Html.ValidationMessageFor(model => model.ac.SizeModifier.Value)
                </td>
                <td style="font-weight:bold; color:Black">Natural:</td>
                <td>
                    @Html.EditorFor(model => model.ac.NaturalArmorModifier.Value)
                    @Html.ValidationMessageFor(model => model.ac.NaturalArmorModifier.Value)
                </td>
                <td style="font-weight:bold; color:Black">Def.:</td>
                <td>
                    @Html.EditorFor(model => model.ac.DeflectionModifier.Value)
                    @Html.ValidationMessageFor(model => model.ac.DeflectionModifier.Value)
                </td>
                <td style="font-weight:bold; color:Black">Misc:</td>
                <td>
                    @Html.EditorFor(model => model.ac.MiscModifier.Value)
                    @Html.ValidationMessageFor(model => model.ac.MiscModifier.Value)
                </td>
            </tr>
            <tr align="center">
                <td colspan="2" style="font-weight:bold; color:Black">Touch:</td>
                <td colspan="2" style="font-weight:bold">
                    @Html.LabelFor(model => model.ac.TouchAC.Value)
                </td>
                <td colspan="2" style="font-weight:bold; color:Black">Flat-Footed:</td>
                <td colspan="2" style="font-weight:bold">
                    @Html.LabelFor(model => model.ac.FlatFootAC.Value)
                </td>
                <td colspan="9"></td>
            </tr>
        </table>
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Combat</h3>
        <table id="BaB" border="1" class="table">
            <tr align="center">
                @{
                    int count = Model.combat.baseAttackBonus.BABS.Count;
                    if (count < 10) {
                        int x = 0;
                        while (x < (10 - count))
                        {
                            DMHelper.Models.NumericalField tmpNum = new DMHelper.Models.NumericalField(0);
                            Model.combat.baseAttackBonus.BABS.Insert(Model.combat.baseAttackBonus.BABS.Count, tmpNum);
                            x += 1;
                        }
                    }
                    foreach (var item in Model.combat.baseAttackBonus.BABS)
                    {
                        <td>
                             @Html.EditorFor(model => @item.Value)
                             @Html.ValidationMessageFor(model => @item.Value)
                         </td>
                     }
                }
            </tr>
        </table>
        <br />
        <table id="AcItemsTraitsLangues" border="1" class="table" align="right">
            <tr align="center">
                <td style="font-weight:bold; color:Black">Equipped armor:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ArmorName.Value)
                    @Html.ValidationMessageFor(model => model.ac.ArmorName.Value)
                </td>
                <td style="font-weight:bold; color:Black">Max Dex:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ArmorMaxDex.Value)
                    @Html.ValidationMessageFor(model => model.ac.ArmorMaxDex.Value)
                </td>
                <td style="font-weight:bold; color:Black">Penalty:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ArmorCheckPenalty.Value)
                    @Html.EditorFor(model => model.ac.ArmorCheckPenalty.Value)
                </td>
                <td style="font-weight:bold; color:Black">Weight</td>
                <td>
                    @Html.EditorFor(model => model.ac.ArmorWeight.Value)
                    @Html.EditorFor(model => model.ac.ArmorWeight.Value)
                </td>
            </tr>
            <tr align="center">
                <td style="font-weight:bold; color:Black">Equipped Shield:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ShieldName.Value)
                    @Html.ValidationMessageFor(model => model.ac.ShieldName.Value)
                </td>
                 <td style="font-weight:bold; color:Black">Max Dex:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ShieldMaxDex.Value)
                    @Html.ValidationMessageFor(model => model.ac.ShieldMaxDex.Value)
                </td>
                <td style="font-weight:bold; color:Black">Penalty:</td>
                <td>
                    @Html.EditorFor(model => model.ac.ShieldCheckPenalty.Value)
                    @Html.ValidationMessageFor(model => model.ac.ShieldCheckPenalty.Value)
                </td>
                <td style="font-weight:bold; color:Black">Weight</td>
                <td>
                    @Html.EditorFor(model => model.ac.ShieldWeight.Value)
                    @Html.ValidationMessageFor(model => model.ac.ShieldWeight.Value)
                </td>
            </tr>
        </table>
        <table id="Weapons" border="1" class="table">
            @foreach (var item in Model.combat.Weapons.Values)
            {
                <tr align="center" style="background-color:Silver">
                    <td style="font-weight:bold; color:Black">Weapon:</td>
                    <td colspan="5" style="font-weight:bold">
                        @Html.EditorFor(model => @item.WeaponName.Value)
                        @Html.ValidationMessageFor(model => @item.WeaponName.Value)
                    </td>
                </tr>
                <tr align="center" style="background-color:Silver;">
                    <td style="font-weight:bold; color:Black;">Attack bonus:</td>
                    <td>
                        @Html.EditorFor(model => @item.WeaponDmgBonus.Value)
                        @Html.ValidationMessageFor(model => @item.WeaponDmgBonus.Value)
                    </td>
                    <td style="font-weight:bold; color:Black;">Damage:</td>
                    <td>
                        @Html.EditorFor(model => @item.Damage.Value)
                        @Html.ValidationMessageFor(model => @item.Damage.Value)
                    </td>
                    <td style="font-weight:bold; color:Black;">Critical:</td>
                    <td>
                        @Html.EditorFor(model => @item.Critical.Value)
                        @Html.ValidationMessageFor(model => @item.Critical.Value)
                    </td>
                </tr>
                <tr align="center" style="background-color:Silver;">
                    <td style="font-weight:bold; color:Black;">Range:</td>
                    <td>
                        @Html.EditorFor(model => @item.Range.Value)
                        @Html.ValidationMessageFor(model => @item.Range.Value)
                    </td>
                    <td style="font-weight:bold; color:Black;">Type:</td>
                    <td>
                        @Html.EditorFor(model => @item.Type.Value)
                        @Html.ValidationMessageFor(model => @item.Type.Value)
                    </td>
                    <td style="font-weight:bold; color:Black;">Notes/ammunitions:</td>
                    <td colspan="2">
                        @Html.EditorFor(model => @item.Notes.Value)
                        @Html.ValidationMessageFor(model => @item.Notes.Value)
                    </td>
                </tr>
            }
        </table>
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Feats and skills</h3>
        <table id="Skills" border="1" class="table" align="right">
            <tr align="center" style="background-color:Silver">
                <td style="font-weight:bold; color:Black">Skill</td>
                <td style="font-weight:bold; color:Black">Ability</td>
                <td style="font-weight:bold; color:Black">Modif.</td>
                <td style="font-weight:bold; color:Black">=</td>
                <td style="font-weight:bold; color:Black">Ranks</td>
                <td style="font-weight:bold; color:Black">+</td>
                <td style="font-weight:bold; color:Black">Ability modif.</td>
                <td style="font-weight:bold; color:Black">+</td>
                <td style="font-weight:bold; color:Black">Misc. modif.</td>
            </tr>
            @*Boucler dans les skills*@
            @foreach (var item in Model.skills.listeSkill.Values)
            {
                <tr align="center">
                    <td>
                        @Html.LabelFor(model => @item.SkillName.Value)
                    </td>
                    <td>
                        @Html.LabelFor(model => @item.keyAbilityName.Value)
                    </td>
                    <td>
                        @Html.EditorFor(model => @item.totalSkill.Value)
                        @Html.ValidationMessageFor(model => @item.totalSkill.Value)
                    </td>
                    <td>=</td>
                    <td>
                        @Html.EditorFor(model => @item.ranksBonus.Value)
                        @Html.ValidationMessageFor(model => @item.ranksBonus.Value)
                    </td>
                    <td>+</td>
                    <td>
                        @Html.EditorFor(model => @item.keyAbilityModifier.Value)
                        @Html.ValidationMessageFor(model => @item.keyAbilityModifier.Value)
                    </td>
                    <td>+</td>
                    <td>
                        @Html.EditorFor(model => @item.miscBonus.Value)
                        @Html.ValidationMessageFor(model => @item.miscBonus.Value)
                    </td>
                </tr>
            }
        </table>
        <table id="Feats" border="1" class="table">
            <tr align="center" style="background-color:Silver">
                <td style="font-weight:bold; color:Black; width:200px">Feats</td>
                <td style="font-weight:bold; color:Black; width:300px">Description</td>
            </tr>
            @*Boucler dans les Feats
            Note: Model.feats.feats => Mindfuck >_<
            *@
            @foreach (var item in Model.feats.feats)
            {
                <tr align="center">
                <td>
                    @Html.EditorFor(model => @item.FeatName.Value)
                    @Html.ValidationMessageFor(model => @item.FeatName.Value)
                </td>
                <td>
                    @Html.EditorFor(model => @item.FeatDescription.Value)
                    @Html.ValidationMessageFor(model => @item.FeatDescription.Value)
                </td>
            </tr>
            }
        </table>
        @*TODO: Ajouter un bouton "AJOUTER UN FEAT" ici !*@
        <br />
        <h3 style="text-align:left; color:White; background-color:Black; font-style:oblique">Inventory</h3>
        <table id="LanguesTraits" border="1" class="table" align="right">
            <tr align="center">
                @*Colonne Traits oubliée lors de la conception de la DB !*@
                @*<td colspan="4" style="font-weight:bold; color:Black; width:200px">Racial traits</td>*@ 
                <td colspan="4" style="font-weight:bold; color:Black; width:200px">Languages</td> 
            </tr>
            @*Boucler dans les traits et les langues*@
            @foreach (var item in Model.language.languages) {
                <tr align="center">
                    <td colspan="4">
                        @Html.EditorFor(model => @item.Value)
                        @Html.ValidationMessageFor(model => @item.Value)
                    </td>            
                </tr>
            }
        </table>
        @*TODO: Ajouter un bouton "AJOUTER UNE LANGUE" ici !*@
        <table id="Inventaire" border="1" class="table">
            <tr align="center">
                <td style="font-weight:bold; color:Black; width:300px">Items</td>
                <td style="font-weight:bold; color:Black; width:20px">Weight</td>
            </tr>
            @*Boucler dans les items*@
            @foreach (var item in Model.equipment.items)
            {
                <tr align="center">
                    <td style="width:300px">
                        @Html.EditorFor(model => @item.Name)
                        @Html.ValidationMessageFor(model => @item.Name)
                    </td>
                    <td style="width:20px">
                        @Html.EditorFor(model => @item.Weight)
                        @Html.ValidationMessageFor(model => @item.Weight)
                    </td>
                </tr>
            }
        </table>
         @*TODO: Ajouter un bouton "AJOUTER UN ITEM" ici !*@
        <br />
        <input id="btnSauvegarder" type="button" value="Sauvegarder" style="width:150px; height:35px;"/>
        <input id="btnAnnuler" type="button" value="Annuler" style="width:150px; height:35px;"/>
        <br />
        <br />
  </fieldset>  
}

@Html.ActionLink("Retour", "Feuille", "Home")